package com.zhuss.repair.processor;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.repair.repairAudit.ChaKanBo;
import com.zhuss.bean.bo.repair.repairAudit.WeiXiuDanBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.db.entity.OpLog;
import com.zhuss.enums.LogActionEnum;
import com.zhuss.enums.MoudleEnum;
import com.zhuss.exception.WpsException;
import com.zhuss.repair.db.dao.ext.RepairDao;
import com.zhuss.repair.db.entity.ChaKan;
import com.zhuss.repair.db.entity.ChaKan_DengJi;
import com.zhuss.repair.db.entity.ChaKan_HeCha;
import com.zhuss.repair.db.entity.ChaKan_KanCha;
import com.zhuss.repair.db.entity.ChaKan_PingJia;
import com.zhuss.repair.db.entity.ChaKan_WeiXiu;
import com.zhuss.repair.db.entity.Goods;
import com.zhuss.repair.db.entity.WeiXiuDanVo;
import com.zhuss.util.JsonUtil;

/**
 * 删除餐品 processor
 * @Author: zhushanshuo
 * @Date: 2020/02/28 16:01
 */
@Component("weiXiuDan")
public class WeiXiuDan extends AbstractProcessor<Object, WeiXiuDanBo> implements Processor<Object, WeiXiuDanBo> {


    @Autowired
    private RepairDao repairDao;
    
    
    /**
     * 校验
     */
	@Override
	@SuppressWarnings("unchecked")
    public void check(WeiXiuDanBo bo) throws WpsException {
    	/*Long repairId = bo.getRepairId();
    	List<Long> permissionIdList = (List<Long>) repairPermissionRead.listPermissionId(repairId);
    	if (!permissionIdList.isEmpty()) {
    		throw new WpsException(ExceptionCode.不能删除已绑定权限的餐品);
    	}
    	List<Long> userIdList = (List<Long>) userRepairRead.listUserId(repairId);
    	if (!userIdList.isEmpty()) {
    		throw new WpsException(ExceptionCode.不能删除已绑定用户的餐品);
    	}*/
    }
    
    /**
     * 操作方法(反馈)
     */
    @Override
    public Object process(WeiXiuDanBo param) throws WpsException {
    	Map<String,Object> map = new HashMap<String,Object>();
    	map.put("repair_id",param.getRepair_id());

    	WeiXiuDanVo result = repairDao.getWeiXiuDan(map);
    	
        return result;
      
    }
    
    

    
    /**
     * 操作日志
     */
	@Override
	public Object log(WeiXiuDanBo param) throws WpsException {
		OpLog record = new OpLog();
    	record.setMoudle(MoudleEnum.维修单.key());
    	record.setAction(LogActionEnum.维修单.key());
    	/*record.setTargetId(param.getRepairId().longValue());*/
    	/*record.setTargetName(param.getRemark());*/
    	record.setContent("参数: " + JsonUtil.toJson(param));
    	record.setReason(param.getExceptionReason());
    	
    	record.setCreatorId(param.getConcurrentUserId());
    	record.setCreator(param.getConcurrentUserName());
    	record.setCreateTime(new Date());
    	log(record);
    	return null;
	}
}
